package system.task.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import framework.utils.JsonUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import system.entity.SysTaskJob;
import system.task.defined.TaskRunStatus;

import javax.persistence.Column;
import java.util.Date;

@Data
public class SysTaskRunning extends SysTaskJob {

    /**
     * 执行状态：加载/停止/运行中/异常
     */
    @Column(name = "run_status")
    @ApiModelProperty(value = "执行状态：加载/停止/运行中/异常")
    private TaskRunStatus runStatus;

    /**
     * 运行描述
     */
    @Column(name = "run_remarks")
    @ApiModelProperty(value = "运行描述")
    private String runRemarks;

    /**
     * 最后运行开始时间
     */
    @Column(name = "run_time_start")
    @ApiModelProperty(value = "最后运行开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    private Date runTimeStart;

    /**
     * 最后运行结束时间
     */
    @Column(name = "run_time_end")
    @ApiModelProperty(value = "最后运行结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    private Date runTimeEnd;

    /**
     * 下次触发时间
     */
    @Column(name = "next_time")
    @ApiModelProperty(value = "下次触发时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    private Date nextTime;

    /**
     * 下次触发时间
     */
    @Column(name = "prev_time")
    @ApiModelProperty(value = "下次触发时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    private Date prevTime;

    /**
     * 下次触发时间
     */
    @Column(name = "sche_time")
    @ApiModelProperty(value = "下次触发时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    private Date scheTime;

    /**
     * 最后装载时间
     */
    @Column(name = "load_time")
    @ApiModelProperty(value = "最后装载时间")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
    private Date loadTime;

    private static final long serialVersionUID = 1L;

    @Override
    public String toString() {
        return JsonUtil.toJsonString(this, true);
    }
}